package com.ywx.yypicturebackend.exception;

public class ThrowUtils {

    /**
     * 条件成立则抛异常
     * @param condition 条件
     * @param exception 异常
     */
    public static void throwIf(boolean condition,RuntimeException exception){
        if(condition){
            throw exception;
        }
    }

    /**
     * 条件成立则抛异常
     * @param condition 条件
     * @param errorCode 错误码
     */
    public static void throwIf(boolean condition,ErrorCode errorCode){
        if(condition){
            throw new BusinessException(errorCode);
        }
    }

    /**
     * 条件成立则抛异常
     * @param condition 条件
     * @param errorCode 错误码
     * @param message 错误信息
     */
    public static void throwIf(boolean condition,ErrorCode errorCode,String message){
        if(condition){
            throw new BusinessException(errorCode,message);
        }
    }



}
